<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        window.onload=()=>{
            let btn=document.getElementById("btn");
            btn.onclick=()=>{
                //获得浏览器名称
                let browser=navigator.appName;
                console.log(browser);
                if (confirm("退出吗")){
                    //判断浏览器类型
                    if(browser==="Netscape"){
                        window.open("about:blank","_self").close();
                    }else {
                        window.close()
                    }
                }
            };
            document.getElementById("b_url").innerHTML=location.href;
            document.getElementById("b_pathname").innerHTML=location.pathname;
            document.getElementById("b_search").innerHTML=location.search;
        }
    </script>
</head>
<body>
    <button id="btn">点击</button>
    <p id="b_url"></p>
    <p id="b_pathname"></p>
    <p id="b_search"></p>
</body>
</html>